import { ApiProperty } from '@midwayjs/swagger';
import { Rule, RuleType } from '@midwayjs/validate';
import { Column, Entity, PrimaryColumn } from 'typeorm';
@Entity('leavemsg')
export class LeaveMessage {
  @Rule(RuleType.string())
  @PrimaryColumn()
  msgID: string;
  @Column()
  @Rule(RuleType.date())
  createDate: string;
  @ApiProperty({
    type: 'string',
    example: 'test' + new Date().getDay(),
  })
  @Column({ type: 'varchar', length: 32 })
  @Rule(RuleType.string().required())
  name: string;
  @ApiProperty({
    type: 'string',
    example: '联系方式',
  })
  @Column()
  @Rule(RuleType.string().allow(null).required())
  contact: string;
  @ApiProperty({
    type: 'string',
    example: '留言',
  })
  @Column()
  @Rule(RuleType.string().required())
  text: string;
  @Column('boolean')
  @Rule(RuleType.boolean())
  isRead: boolean;
}
export class LeaveMessageQuery {
  @ApiProperty({
    type: 'string',
    example: '',
  })
  @Rule(RuleType.string().allow(null).allow(''))
  name: string;
  @ApiProperty({
    type: 'number',
    example: 1,
  })
  @Rule(RuleType.number().min(1).required())
  pageIndex: number;
  @ApiProperty({
    type: 'number',
    example: 20,
  })
  @Rule(RuleType.number().min(1).required())
  pageSize: number;
  @ApiProperty({
    type: 'string',
    example: '',
  })
  @Rule(RuleType.string().allow(null).allow(''))
  DateBegin: string;
  @ApiProperty({
    type: 'string',
    example: '',
  })
  @Rule(RuleType.string().allow(null).allow(''))
  DateEnd: string;
}
